package com.iplay.thezen.iterator;

import java.util.Vector;

/**
 * @author dangwu
 * @since 2021/9/16 6:38 下午
 */
public class ConcreteIterator implements Iterator{
    private Vector vector = new Vector();
    public int cursor = 0;
    public ConcreteIterator(Vector vector){
        this.vector = vector;
    }
    @Override
    public Object next() {
        Object result;
        if (this.hasNext()){
            result = this.vector.get(this.cursor++);
        }else {
            return null;
        }
        return result;
    }

    @Override
    public boolean hasNext() {
        return this.cursor != this.vector.size();
    }

    @Override
    public boolean remove() {
        this.vector.remove(this.cursor);
        return true;
    }
}
